Fixes Register Endpoint for Router of Instance of APIWebSocketRoute#358
Closed
HideyoshiNakazone wants to merge 4 commits intofastapiutils:masterfrom
HideyoshiNakazone:fixes-websocket-implementation
Closed
Fixes Register Endpoint for Router of Instance of APIWebSocketRoute#358HideyoshiNakazone wants to merge 4 commits intofastapiutils:masterfrom HideyoshiNakazone:fixes-websocket-implementation
HideyoshiNakazone wants to merge 4 commits intofastapiutils:masterfrom
HideyoshiNakazone:fixes-websocket-implementation
Conversation
Author
|
Hey @yuval9313, could you or another maintainer take a look in this merge request please? Thanks a lot, |
yuval9313
requested changes
Feb 18, 2025
Collaborator
yuval9313
left a comment
There was a problem hiding this comment.
You are also missing test case
fastapi_utils/cbv.py
Outdated
| for route in router.routes: | ||
| if not isinstance(route, APIRoute): | ||
| raise ValueError("The provided routes should be of type APIRoute") | ||
| if not isinstance(route, APIRoute) and not isinstance(route, APIWebSocketRoute): |
Collaborator
There was a problem hiding this comment.
I'm sorry, this is really nit pick but I prefer not (condition a or condition b)
Author
There was a problem hiding this comment.
Not a problem at all, i'll happily make the change :)
Author
Hello, I've added a test case in the unittests for the websocket example, it tests the three basic operations on the websocket connection (can accept connection, can send_text, receive_text and can close). I hope this test is okay :) |
Author
|
Hello @yuval9313 , can we resume this MR? I'd love to have this merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Versions
Python Version: 3.13
Package Versions:
Bug
When creating a Route of type
APIWebSocketRoutethe following error is thrown:This error can be replicated using the following example:
Solution
The solution i recommend is to just add the class to instance check of the
_register_endpointsfunction and then add it with a fixedroute_methodof"WS"since theAPIWebSocketRoutedoes not have amethodsatribute.Thank you very much,
Vitor Hideyoshi.